package com.ww.java.generic.wildcard.unbound;

import java.util.HashMap;
import java.util.Map;

public class UnboundedWildcards2 {

	@SuppressWarnings("rawtypes")
	static Map map1;
	
	static Map<?, ?> map2;
	
	static Map<String, ?> map3;
	
	@SuppressWarnings("rawtypes")
	static void assign1(Map map) {
		map1 = map;
	}
	
	static void assign2(Map<?, ?> map) {
		map2 = map;
	}
	
	static void assign3(Map<String, ?> map) {
		map3 = map;
	}
	
	/**
	 * List表示：持有任何Object类型的原生List
	 * List<?>表示：具有某种特定类型的非原生List，只是我们不知道那种类型是什么
	 * @param args
	 */
	@SuppressWarnings({ "rawtypes", "unchecked" })
	public static void main(String[] args) {
		assign1(new HashMap());
		assign2(new HashMap());
		// Warning
		// Type safety: The expression of type HashMap needs unchecked conversion to conform to Map<String,?>
		assign3(new HashMap());
		
		assign1(new HashMap<String, Integer>());
		assign2(new HashMap<String, Integer>());
		assign3(new HashMap<String, Integer>());
	}
}
